﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using DAL;
using FCTC_Web.DAL;
using FCTC_Web.Models;
using System.Data.Entity;
using FCTC_Web.Utilities;
using Combres;
namespace FCTC_Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.AddCombresRoute("combres");
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
            routes.MapRoute(
               "Default", // Route name
               "{controller}/{action}/{id}", // URL with parameters
                // new { controller = "Default", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                 new { controller = "SessionArrangement", action = "Index", id = UrlParameter.Optional } // Parameter defaults
           );


        }

        protected void Application_Start()
        {
            XmlHelper.FileName = "Vehicles.xml";
            CH.AddMapping(typeof(Estimator), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(Vehicle), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(Case), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(Shop), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(ImageModel), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(VehicleEstimation), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(Personal), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(Article), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(Team), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(TeamMember), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(SessionArrangement), typeof(FCTC_DataContext), "ID");
            CH.AddMapping(typeof(SessionUnit), typeof(FCTC_DataContext), "ID");
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}